package com;

import com.hqbzl.HelloServiceImpl;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class HelloServerHandler extends ChannelInboundHandlerAdapter {
	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg) {

		// 如何符合约定，则调用本地方法，返回数据
//		if (msg.toString().startsWith(ClientBootstrap.providerName)) {
//			String result = new HelloServiceImpl().hello(msg.toString().substring(msg.toString().lastIndexOf("#") + 1));
//			ctx.writeAndFlush(result);
//		}
		String result = new HelloServiceImpl().hello(msg.toString().substring(msg.toString().lastIndexOf("#") + 1));
		ctx.writeAndFlush(result);
	}
}